<?php
/**
 * Created by PhpStorm.
 * User: zengyongnhua
 * Date: 2020/9/10
 * Time: 3:41 PM
 */
testReplace([]);

function testReplace($data)
{
	$str='#menu a.frameoff { background-image: url({IMGDIR}/frame_off.gif); }';

	$data['imgdir']="nihao";
	$cssdata = preg_replace_callback("/\{([A-Z0-9]+)\}/",  function ($matches) use ($data) {
		return  $data[strtolower($matches[1])];
	}, $str);
	echo  $cssdata;
	exit(1);
}

$source = fopen("demo.php","rb");

$conn = ftp_connect("47.113.205.45") or die("Could not connect");

ftp_login($conn,"zeng","4339483");
ftp_pasv($conn, false);
ftp_chdir($conn, "test");
$state= ftp_nb_fput($conn,"demo3.php",$source,FTP_BINARY);
echo  "state:".$state;
ftp_close($conn);

exit(0);
$str="[userinfo][calendar][myreplies][myfavforums]";
$items=explode('][', ']'.$str.'[');
var_dump($items);

$str="userinfo][calendar][myreplies][myfavforums";
$items=explode('][', ']'.$str.'[');
var_dump($items);
$advcount=6;
if($advcount > 5)
{
    $minfillpercent = 0;
    for($cols = 5; $cols >= 3; $cols--)
    {
        $var1=$advcount % $cols;

        echo "var1:".$var1."\n";

        if(($remainder = $advcount % $cols) == 0)
        {
            $advcols = $cols;
            break;
        } else
        {
            $var2=$remainder / $cols ;
            echo "var2:".$var2."\n";
            if($remainder / $cols > $minfillpercent)  {
                $minfillpercent = $remainder / $cols;
                $advcols = $cols;
            }

        }
    }
}
else {
    $advcols = $advcount;//一行显示几个文字广告
}
echo "2col:".$advcols;

$value1=sprintf('%00b', 3);
echo "\ncol:".$value1;
$value1=sprintf('%00b', 2);
echo "\ncol:".$value1;
$value1=sprintf('%00b', 1);
echo "\ncol:".$value1;
$value1=sprintf('%00b', 0);
echo "\ncol:".$value1;
$password="123456";
$salt="5173d5";
$password = md5(md5($password).$salt);

echo  "\npwd:".$password;

#testCurl();
function testCurl()
{
    $ch = curl_init();
    $ip='';
    $host="zengyonghua.site";
    $ip && curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: ".$host));
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Safari/604.1.38");
    curl_setopt($ch, CURLOPT_URL, "https://zengyonghua.site:443/discuz35/api/uc.php?code=d7ecKmLHnbRGK2EN4QaYcl5FHKNtVUg1Uu5%2FkMOf4yeZ9VhQdkMX%2BYtuIysBS27n1NhLEhjgFqQ");
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
    $data = curl_exec($ch);
    $status = curl_getinfo($ch);
    var_dump($status ) ;
    $errno = curl_errno($ch);
    curl_close($ch);
    if($errno || $status['http_code'] != 200) {
        return;
    }
}

